﻿using Spacebuilder.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Tunynet;
using Tunynet.Common;

namespace Spacebuilder.Group
{
    /// <summary>
    /// 用于处理用户空间权限的过滤器
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
    public class GroupMemberAuthorizeAttribute : Attribute
    {

        /// <summary>
        /// 判断是否是商户成员
        /// </summary>
        public static string Ismember(string SpaceKey)
        {
            IUser user = UserContext.CurrentUser;
            string str = string.Empty;
            if(user==null)
                return "找不到当前用户";

            GroupService groupService = new GroupService();
            GroupEntity group = groupService.Get(user.UserName);
            if (group == null)
                return "找不到当前商户";

            return str;

        }

    }
}